﻿using System.Collections.Generic;

namespace JuCheap.Core.Aop.Extensions
{
    /// <summary>
    /// 字典扩展
    /// </summary>
    internal static class DictionaryExtension
    {
        /// <summary>
        /// 添加(如果存在指定的key，就更新)
        /// </summary>
        public static void AddOrUpdate<T, K>(this IDictionary<T, K> keyValuePairs, T key, K value)
        {
            if (keyValuePairs.ContainsKey(key))
                keyValuePairs[key] = value;
            else
                keyValuePairs.Add(key, value);
        }
    }
}
